﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CoolERP_BLL;
using CoolERP_Entities;

namespace CoolERP_Web.User
{
    [PermissionCheck(false)]
    public partial class SelectHTCP : BasePage
    {        
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (this.GetUrlParam("ids") != null)
                    hidSelIds.Value = this.GetUrlParam("ids").ToString();
                txtE_Time.Text = DateTime.Now.AddDays(3).ToString("yyyy-MM-dd");
                this.AspNetPager1.PageSize = GridView1.PageSize;
                BindData();
            }
        }

        protected void btnQuery_Click(object sender, EventArgs e)
        {
            BindData();
        }

        private void BindData()
        {
            int RecordCount = 0;
            Dictionary<string, string> dc = new Dictionary<string, string>();
            dc.Add("HTZT", "1");
            if (!string.IsNullOrEmpty(hidSelIds.Value))
                dc.Add("NotID", hidSelIds.Value);
            if (!string.IsNullOrEmpty(txtHTBH.Text.Trim()))
                dc.Add("HTBH", txtHTBH.Text.Trim());
            if (!string.IsNullOrEmpty(txtKHJC.Text.Trim()))
                dc.Add("KHJC", txtKHJC.Text.Trim());
            if (!string.IsNullOrEmpty(txtCPBH.Text.Trim()))
                dc.Add("CPBH", txtCPBH.Text.Trim());
            if (!string.IsNullOrEmpty(txtS_Time.Text.Trim()))
                dc.Add("sDate", txtS_Time.Text.Trim());
            if (!string.IsNullOrEmpty(txtE_Time.Text.Trim()))
                dc.Add("eDate", txtE_Time.Text.Trim());
            using (XSHTMXBBLL xBLL = new XSHTMXBBLL())
            {
                List<XSHTMXBModel> mxbs = xBLL.GetSCJH_HTMXB(dc, "CPBH", this.AspNetPager1.CurrentPageIndex, this.AspNetPager1.PageSize, out RecordCount);
                GridView1.DataSource = mxbs;
                GridView1.DataBind();
                this.AspNetPager1.RecordCount = RecordCount;
                this.AspNetPager1.Visible = RecordCount > 0;
                panMsg.Visible = !this.AspNetPager1.Visible;
            }
        }

        protected void AspNetPager1_PageChanged(object sender, EventArgs e)
        {
            BindData();
        }
    }
}